package com.baizhi.springboot.service.impl;

import com.baizhi.springboot.dao.MeetingDao;
import com.baizhi.springboot.entity.Inform;
import com.baizhi.springboot.entity.Meeting;
import com.baizhi.springboot.service.MeetingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class MeetingServiceImpl implements MeetingService {
    @Autowired
    private MeetingDao meetingDao;


    @Override
    public Map selectMeetingByPage(Integer page, Integer limit) {
        Integer offset=(page-1)*limit;
        List<Meeting> meetings = meetingDao.selectMeetingByPage(offset, limit);
        Integer count = meetingDao.selectCount();
        /* "code": 0,
          "msg": "",
          "count": 1000,
          "data": [{}, {}]*/
        HashMap<Object, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", meetings);
        return map;
    }

    @Override
    public void insertMeeting(Meeting meeting) {
        meetingDao.insertMeeting(meeting);
    }

    @Override
    public void deleteMeeting(Integer id) {
        meetingDao.deleteMeeting(id);
    }

    @Override
    public Meeting selectOneMeeting(Integer id) {
        return meetingDao.selectOneMeeting(id);
    }

    @Override
    public void updateMeeting(Meeting meeting) {
        meetingDao.updateMeeting(meeting);
    }
}
